<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
         <script src="js/jquery.js"></script>
	</head>
	<body>
        <script> 
            /* 绑定事件 */
            	var book_id;
                var account;
                  var url=window.location.search;
                  if(url.indexOf("?")!=-1){
                  var str = url.substr(1);
                     strs = str.split("&"); 
                     var key=new Array(strs.length);
                     var value=new Array(strs.length);
                     for(i=0;i<strs.length;i++){
                      key[i]=strs[i].split("=")[0]
                      value[i]=unescape(strs[i].split("=")[1]);
                    } 
                    book_id=value[0];
                    account=value[1];
                  } 
                 var json={"book_id":book_id,"account":account};
                 var jsonstr=JSON.stringify(json);
                    $.ajax({
                        
                        type:'post',
                         url:'http://127.0.0.1:8080/borrow',
                           contentType:"application/json;chartset=utf-8",
                         data:jsonstr,
                        success:function(){
                             alert("借书成功");
                             window.location.href='User_book.html?account='+account;
                        },
                         error:function(){
                                alert("借书失败,请重新操作");
                               window.location.href='User_book.htmlaccount='+account;
                            }
                            
                    })
                    
            	
            	
            
        	
           
         
                
            </script>
	</body>
</html>
